﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;

namespace DataAccess
{
    public class InfoKetQuaThucHienDT
    {
        private string _MaKQ;

        public string MaKQ
        {
            get { return _MaKQ; }
            set { _MaKQ = value; }
        }
        private string _MSSV;

        public string MSSV
        {
            get { return _MSSV; }
            set { _MSSV = value; }
        }
        public string SinhVien
        {
            get
            {
                try
                {
                    return InfoSinhVien.TimKiemSinhVienTheoMa(this.MSSV)[0].HoTenSV;
                }
                catch
                {
                    return "";
                }
            }
        }
        private string _MaGVHD;

        public string MaGVHD
        {
            get { return _MaGVHD; }
            set { _MaGVHD = value; }
        }
        public string GiaoVienHuongDan
        {
            get
            {
                try
                {
                    return InfoGiaoVien.TimKiemTheoMaGV(this.MaGVHD)[0].HoTenGV;
                }
                catch
                {
                    return "";
                }
            }
        }
        private string _MaGVPB1;

        public string MaGVPB1
        {
            get { return _MaGVPB1; }
            set { _MaGVPB1 = value; }
        }
        public string GiaoVienPhanBien1
        {
            get
            {
                try
                {
                    return InfoGiaoVien.TimKiemTheoMaGV(this.MaGVPB1)[0].HoTenGV;
                }
                catch
                {
                    return "";
                }
            }
        }
        private string _MaGVPB2;

        public string MaGVPB2
        {
            get { return _MaGVPB2; }
            set { _MaGVPB2 = value; }
        }
        public string GiaoVienPhanBien2
        {
            get
            {
                try
                {
                    return InfoGiaoVien.TimKiemTheoMaGV(this.MaGVPB2)[0].HoTenGV;
                }
                catch
                {
                    return "";
                }
            }
        }
        private int _SoCD;

        public int SoCD
        {
            get { return _SoCD; }
            set { _SoCD = value; }
        }
        private int _SoBai;

        public int SoBai
        {
            get { return _SoBai; }
            set { _SoBai = value; }
        }
        private float _Diem1;

        public float Diem1
        {
            get { return _Diem1; }
            set { _Diem1 = value; }
        }
        private float _Diem2;

        public float Diem2
        {
            get { return _Diem2; }
            set { _Diem2 = value; }
        }
        private float _Diem3;

        public float Diem3
        {
            get { return _Diem3; }
            set { _Diem3 = value; }
        }
        private string _MaDT;

        public string MaDT
        {
            get { return _MaDT; }
            set { _MaDT = value; }
        }
        public string TenDeTai
        {
            get
            {
                try
                {
                    return InfoDeTai.TimKiemTheoMaDeTai(this.MaDT)[0].TenDT;
                }
                catch { return ""; }
            }
        }
        public InfoKetQuaThucHienDT()
        { }
        public static List<InfoKetQuaThucHienDT> DanhSachKQThucHienDT()
        {
            return CBO.FillCollection<InfoKetQuaThucHienDT>(DataProvider.Instance.ExecuteReader("KetQuaDeTai_Select"));
        }
        //Them mot ket qua de tai
        public static int AddKetQuaDeTai(InfoKetQuaThucHienDT infokqdetai)
        {
            return DataProvider.Instance.ExecuteNonquery("KetQuaDeTai_Add", infokqdetai.MaKQ, infokqdetai.MSSV, infokqdetai.MaGVHD, infokqdetai.MaGVPB1, infokqdetai.MaGVPB2,
                            infokqdetai.SoCD, infokqdetai.SoBai, infokqdetai.Diem1, infokqdetai.Diem2, infokqdetai.Diem3, infokqdetai.MaDT);
        }
        // Xoa mot ket qua de tai
        public static int DeleteKetQuaDeTai(string delete)
        {
            return DataProvider.Instance.ExecuteNonquery("KetQuaDeTai_Delete", delete);
        }
        //Update mot ket qua de tai
        public static int UpdateKetQuaDeTai(InfoKetQuaThucHienDT infokqdetai)
        {
            return DataProvider.Instance.ExecuteNonquery("KetQuaDeTai_Update", infokqdetai.MaKQ, infokqdetai.MSSV, infokqdetai.MaGVHD, infokqdetai.MaGVPB1, infokqdetai.MaGVPB2,
                            infokqdetai.SoCD, infokqdetai.SoBai, infokqdetai.Diem1, infokqdetai.Diem2, infokqdetai.Diem3, infokqdetai.MaDT);
        }
        
        // Tim kiem theo ma maKQ
        public static List<InfoKetQuaThucHienDT> TimKiemTheoMaKQ(string ma)
        {
            return CBO.FillCollection<InfoKetQuaThucHienDT>(DataProvider.Instance.ExecuteReader("KetQuaDeTai_TimKiemMa", ma));
        }
        //Tim kiem theo ho ten
        public static List<InfoKetQuaThucHienDT> TimKiemTheoTenMSSV(string mssv)
        {
            return CBO.FillCollection<InfoKetQuaThucHienDT>(DataProvider.Instance.ExecuteReader("KetQuaDeTai_TimKiemTheoTenSV", mssv));
        }
        //Tim kiem theo dia chi
        public static List<InfoKetQuaThucHienDT> TimKiemTheoGVPB1(string tengv)
        {
            return CBO.FillCollection<InfoKetQuaThucHienDT>(DataProvider.Instance.ExecuteReader("KetQuaDeTai_TimGiaoVienPB1", tengv));
        }

        public static List<InfoKetQuaThucHienDT> TimKiemTheoGVPB2(string tengv)
        {
            return CBO.FillCollection<InfoKetQuaThucHienDT>(DataProvider.Instance.ExecuteReader("KetQuaDeTai_TimGiaoVienPB2", tengv));
        }

        public static List<InfoKetQuaThucHienDT> TimKiemTheoGVHD(string tengv)
        {
            return CBO.FillCollection<InfoKetQuaThucHienDT>(DataProvider.Instance.ExecuteReader("KetQuaDeTai_TimGiaoVien", tengv));
        }

        public static List<InfoKetQuaThucHienDT> TimKiemTheoTenDT(string tengv)
        {
            return CBO.FillCollection<InfoKetQuaThucHienDT>(DataProvider.Instance.ExecuteReader("KetQuaDeTai_TimTheoTenDT", tengv));
        }











        // Thong ke so luong gia vien theo ma
        public static int ThongKeTheoMaKQ()
        {
            object result = DataProvider.Instance.ExecuteScalar("KetQuaDeTai_ThongKeMaKQ");
            return Convert.ToInt32(result);
        }
        //Thong ke theo ho ten
        public static int ThongKeTheoTenMSSV(string massv)
        {
            object result = DataProvider.Instance.ExecuteScalar("KetQuaThuHienDeTai_ThongKeTenSV", massv);
            return Convert.ToInt32(result);
        }
        //Thong ke theo dia chi
        public static int ThongKeTheoGVPB1(string sobai)
        {
            object result = DataProvider.Instance.ExecuteScalar("KetQuaThuHienDeTai_ThongKeGiaoVienGVPB1", sobai);
            return Convert.ToInt32(result);
        }
        //Thong ke theo dia chi
        public static int ThongKeTheoGVPB2(string socd)
        {
            object result = DataProvider.Instance.ExecuteScalar("KetQuaThuHienDeTai_ThongKeGiaoVienGVPB2", socd);
            return Convert.ToInt32(result);
        }
        public static int ThongKeTheoGVHD(string socd)
        {
            object result = DataProvider.Instance.ExecuteScalar("KetQuaThuHienDeTai_ThongKeGiaoVienTheoTen", socd);
            return Convert.ToInt32(result);
        }
        public static int ThongKeTheoTenDT(string socd)
        {
            object result = DataProvider.Instance.ExecuteScalar("KetQuaThuHienDeTai_ThongKeTenDeTai", socd);
            return Convert.ToInt32(result);
        }

    }
}
